<template>
	<view>
		<view class="fixed">
			<!-- 状态栏 -->
			<view class="statusBar" :style="'height:'+statusBarHeight+'px'"></view>
			<view class="myheader padding-sm font-sub-title">
				预警
			</view>
		</view>
		<view v-if="varList.length==0" class="no_data">
			<image src="../../static/img/no_data.png" class="no_data_img" mode="widthFix">
			<view class="font-sub-title">暂无数据</view>
		</view>
		<view v-else class="cu-list menu" :style="{marginTop:navHeight}">
			<view class="cu-list menu-avatar">
				<view class="cu-item arrow flex-direction justify-between padding-sm" style="height: auto;" v-for="data in varList" @click="goDetail(data.userId,data.name)">
					<view class="flex" style="width: 730rpx;">
						<view class="flex align-center margin-left-sm" >
							<view class="cu-avatar font-normal bg-myBlue margin-right-sm">{{data.name.substring(0,1)}}</view>
							<view>
								<view>
									<text class="font-normal">{{data.name}}</text>
								</view>
								<view class="flex">
									<view class="font-normal"><text>预警总数：</text><text class="text-red margin-right">{{data.total}}</text></view>
									<view class="font-normal"><text>未处理数：</text><text class="text-red">{{data.notDeal}}</text></view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	var that
	export default {
		computed:{
			...mapGetters(['navHeight']),
		},
		data() {
			return {
				statusBarHeight: Vue.prototype.StatusBar,
				varList:[],
				role: uni.getStorageSync("role"),
			}
		},
		onLoad(){
			that = this;
		},
		onShow() {
			this.getData()
		},
		
		onPullDownRefresh() {
			this.getData()
		},
		methods: {
			getData(){
				var user = uni.getStorageSync("userInfo")
				if(this.role=='user'){
					this.$http.getFollowInfo({
						
					}).then(res=>{
						uni.stopPullDownRefresh()
						if(res.code==1){
							that.varList = res.result
						}else{
							uni.showToast({
								title:res.msg,
								position:bottom,
								icon:none
							})
						}
					})
				}else{
					this.$http.getSignedUserInfo ({}).then(res=>{
						uni.stopPullDownRefresh()
						if(res.code==1){
							that.varList = res.result
						}else{
							uni.showToast({
								title:res.msg,
								position:bottom,
								icon:none
							})
						}
					})
				}
			},
			goDetail(id,name){
				uni.navigateTo({
					url:'/pages/warn/detail?id='+id+"&name="+name
				})
			}
		}
	}
</script>

<style>
	.no_data {
		margin-top: 150rpx;
	}

	.no_data_img {
		margin-top: 150rpx;
	}
	.bg-myBlue {
		background-color: #6496E8
	}
	.cu-avatar {
		border-radius: 5px;
	}
</style>
